import urllib
# import urllib2
import requests

url = 'http://www.blog.pythonlibrary.org/wp-content/uploads/2012/06/wxDbViewer.zip'

# # 第一种 urlretrive   第一种用得比较多
# print("downloading with urllib")
# urllib.urlretrieve(url, "code.zip")
#
# 第二种 urlopen 然后写入文件
# print("downloading with urllib2")
# f = urllib2.urlopen(url)
# data = f.read()
# with open("code2.zip", "wb") as code:
#     code.write(data)


# 第三种 requests.get 然后写入文件
print ("downloading with requests")
r = requests.get(url)
with open("d:\\code3.zip", "wb") as code:
     code.write(r.content)